import { NoSkinCellRenderer } from "../../../common/item/NoSkinCellRenderer";
import { GLoadedButton } from "../../../../../../com/mui/controls/GLoadedButton";
import { SGuildPlayerAttendanceVo } from "../vo/SGuildPlayerAttendanceVo";
import { Cache } from "../../../../cache/Cache";
import { EGuildAssignType } from "../../../../../../Message/Game/EGuildAssignType";
import { GlobalStyle } from "../../../../../common/global/GlobalStyle";
import { DisplayUtil } from "../../../../../common/DisplayUtil";
import { EGuildPosition } from "../../../../../../Message/Game/EGuildPosition";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { AvatarInfo } from "../../../../resource/info/AvatarInfo";
import { AvatarType } from "../../../../resource/info/AvatarType";
import { ImageInfo } from "../../../../../../com/gengine/resource/info/ImageInfo";
import { Language } from "../../../../../../extend/language/Language";
import { ObjCreate } from "../../../common/ObjCreate";
import { ResFileConst } from "../../../../resource/ResFileConst";
import { GTextFiled } from "../../../../../../com/mui/controls/GTextFiled";
import { GCheckBox } from "../../../../../../com/mui/controls/GCheckBox";
import { Vector } from "../../../../../../__AS3__/vec/Vector";
type int = number;
//class GuildMemberItemRenderer
    
    export  class GuildMemberItemRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            this._leagueWarStarData = new Vector.<GLoadedButton>();
            this._bossStarData = new Vector.<GLoadedButton>();
            this._robCityStarData = new Vector.<GLoadedButton>();
            this._leagueWarStarSp = new Object /* flash.display.Sprite */();
            this._bossStarSp = new Object /* flash.display.Sprite */();
            this._robCitySp = new Object /* flash.display.Sprite */();
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var arg0: Object;
            var resourceAllocationType: int;
            var imgName: string;

            var loc1;
            resourceAllocationType = 0;
            imgName = null;
            arg0 = arg1;
            if (typeof arg0 === "sguildplayerattendancevo") 
            {
                super.data = arg0 as SGuildPlayerAttendanceVo;
                this._itemData = arg0 as SGuildPlayerAttendanceVo;
                resourceAllocationType = Cache.instance.guild.resourceAllocationType;
                if (SGuildPlayerAttendanceVo(data).isSelect) 
                {
                    if (resourceAllocationType != EGuildAssignType._EGuildAssignSingle) 
                    {
                        this._multiSelect.visible = true;
                        this._multiSelect.selected = true;
                    }
                    else 
                    {
                        this._multiSelect.visible = false;
                    }
                    this.addChildAt(this._overSkin, 0);
                    this._name.textColor = GlobalStyle.color6Uint;
                    this._contribution.textColor = GlobalStyle.color6Uint;
                }
                else 
                {
                    if (resourceAllocationType != EGuildAssignType._EGuildAssignSingle) 
                    {
                        this._multiSelect.visible = true;
                        this._multiSelect.selected = false;
                    }
                    else 
                    {
                        this._multiSelect.visible = false;
                    }
                    DisplayUtil.removeMe(this._overSkin);
                    this._contribution.textColor = GlobalStyle.color1Uint;
                }
                if (this._itemData.itemData.position != EGuildPosition._EGuildLeader) 
                {
                    if (this._itemData.itemData.position != EGuildPosition._EGuildDeputyLeader) 
                    {
                        if (this._itemData.itemData.position != EGuildPosition._EGuildPresbyter) 
                        {
                            this._name.textColor = 16777215;
                            this._bmpPost.bitmapData = null;
                        }
                        else 
                        {
                            this._name.textColor = 65280;
                            this._bmpPost.bitmapData = GlobalClass.getBitmapData(ImagesConst.ChatGuildMember_star);
                        }
                    }
                    else 
                    {
                        this._name.textColor = 48895;
                        this._bmpPost.bitmapData = GlobalClass.getBitmapData(ImagesConst.ChatGuildMember_moon);
                    }
                }
                else 
                {
                    this._name.textColor = 16711935;
                    this._bmpPost.bitmapData = GlobalClass.getBitmapData(ImagesConst.ChatGuildMember_sun);
                }
                if (resourceAllocationType == EGuildAssignType._EGuildAssignBatch) 
                {
                    this._bmpPost.bitmapData = null;
                }
                this._bmpPost.width = 20;
                this._bmpPost.height = 20;
                imgName = AvatarInfo.getPlayerAvatarName(this._itemData.itemData.miniPlayer.camp, this._itemData.itemData.miniPlayer.sex, AvatarType.FRIEND, this._itemData.itemData.miniPlayer.avatarId);
                with ({}) 
                {
                };
                imgName.load(
#error('pushwith') {}
                , 
#error('pushwith') {}
                .onAvatarLoaded = (arg1: ImageInfo): void
                {
                    _avatarBitmap.bitmapData = arg1.bitmapData;
                    _avatarBitmap.width = 20;
                    _avatarBitmap.height = 20;
                    return;
                })
                this._name.text = SGuildPlayerAttendanceVo(data).itemData.miniPlayer.name;
                this._contribution.text = SGuildPlayerAttendanceVo(data).itemData.totalContribute.toString();
                this.leagueWarStarSp = SGuildPlayerAttendanceVo(data).itemData.num1;
                this.bossStarSp = SGuildPlayerAttendanceVo(data).itemData.num2;
                this.setRobCitySp(this._itemData.itemData.num3, this._itemData.itemData.num4, this._itemData.itemData.num5);
                this._multiSelect.invalidate();
                this._multiSelect.drawNow();
            }
            return;
        }

        /* internal  */set leagueWarStarSp(arg1: int)
        {
            var loc2=null;
            DisplayUtil.removeAllChild(this._leagueWarStarSp);
            var loc1=0;
            while (loc1 < arg1) 
            {
                loc2 = this._leagueWarStarData[loc1] as GLoadedButton;
                loc2.x = loc1 * 19;
                loc2.toolTipData = Language.getString(27976);
                this._leagueWarStarSp.addChild(loc2);
                ++loc1;
            }
            return;
        }

        /* internal  */set bossStarSp(arg1: int)
        {
            var loc2=null;
            DisplayUtil.removeAllChild(this._bossStarSp);
            var loc1=0;
            while (loc1 < arg1) 
            {
                loc2 = this._bossStarData[loc1] as GLoadedButton;
                loc2.x = loc1 * 19;
                loc2.toolTipData = Language.getString(27977);
                this._bossStarSp.addChild(loc2);
                ++loc1;
            }
            return;
        }

        /* internal  */setRobCitySp(arg1: int, arg2: int, arg3: int): void
        {
            var loc1=null;
            DisplayUtil.removeAllChild(this._robCitySp);
            if (arg1 >= 1) 
            {
                (loc1 = this._robCityStarData[0] as GLoadedButton).toolTipData = Language.getString(27978);
                this._robCitySp.addChild(loc1);
                loc1.x = (19 * this._robCitySp.numChildren - 1);
            }
            if (arg2 >= 1) 
            {
                (loc1 = this._robCityStarData[1] as GLoadedButton).toolTipData = Language.getString(27979);
                this._robCitySp.addChild(loc1);
                loc1.x = (19 * this._robCitySp.numChildren - 1);
            }
            if (arg3 >= 1) 
            {
                (loc1 = this._robCityStarData[2] as GLoadedButton).toolTipData = Language.getString(27980);
                this._robCitySp.addChild(loc1);
                loc1.x = (19 * this._robCitySp.numChildren - 1);
            }
            return;
        }

        protected onMouseOverHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!this.contains(this._selectLine)) 
            {
                this.addChildAt(this._selectLine, 0);
            }
            return;
        }

        protected onMouseOutHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            DisplayUtil.removeMe(this._selectLine);
            return;
        }

        /* internal  */init(): void
        {
            var loc2=null;
            var loc3=null;
            var loc4=null;
            this._overSkin = new Object /* flash.display.Sprite */();
            this._overSkin.graphics.beginFill(880761, 1);
            this._overSkin.graphics.lineStyle(2, 16744192, 0);
            this._overSkin.graphics.drawRoundRect(1, 0, 398, (32 - 1), 6, 6);
            this._overSkin.graphics.endFill();
            this._overSkin.mouseEnabled = false;
            this._overSkin.cacheAsBitmap = true;
            addChild(this._overSkin);
            this._bmpPost = new Object /* flash.display.Bitmap */();
            ObjCreate.setObjAttri(this._bmpPost, 2, 6, 20, 20, this);
            this._avatarBitmap = new Object /* flash.display.Bitmap */();
            ObjCreate.setObjAttri(this._avatarBitmap, 23, 7, 20, 20, this);
            this._name = ObjCreate.createGTextField("", 43, 8, 90, 20, this);
            this._contribution = ObjCreate.createGTextField("", 128, 8, 60, 20, this);
            this._leagueWarStarSp = new Object /* flash.display.Sprite */();
            ObjCreate.setObjAttri(this._leagueWarStarSp, 190, 8, -1, -1, this);
            this._bossStarSp = new Object /* flash.display.Sprite */();
            ObjCreate.setObjAttri(this._bossStarSp, 260, 8, -1, -1, this);
            this._robCitySp = new Object /* flash.display.Sprite */();
            ObjCreate.setObjAttri(this._robCitySp, 312, 8, -1, -1, this);
            this._multiSelect = ObjCreate.createCheckBox("", 4, 3, 100, 28, this);
            this._multiSelect.visible = false;
            var loc1=0;
            while (loc1 < 3) 
            {
                loc2 = ObjCreate.createGLoadedButton(ResFileConst.GuildResourceAllocationStarBtn, 0, 0, 18, 17);
                loc3 = ObjCreate.createGLoadedButton(ResFileConst.GuildResourceAllocationStarBtn, 0, 0, 18, 17);
                loc4 = ObjCreate.createGLoadedButton(ResFileConst.GuildResourceAllocationStarBtn, 0, 0, 18, 17);
                this._leagueWarStarData.push(loc2);
                this._bossStarData.push(loc3);
                this._robCityStarData.push(loc4);
                ++loc1;
            }
            this._selectLine = new Object /* flash.display.Sprite */();
            this._selectLine.mouseEnabled = false;
            this._selectLine.graphics.lineStyle(2, 65407, 1);
            this._selectLine.graphics.drawRoundRect(1, 0, 398, 33, 6, 6);
            this._selectLine.graphics.endFill();
            ObjCreate.createBg(0, 30, 400, 3, this, ImagesConst.SplitLine);
            this.addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.onMouseOverHandler);
            this.addEventListener(flash.events.MouseEvent.MOUSE_OUT, this.onMouseOutHandler);
            return;
        }

        /* internal */ /* var */_avatarBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_name: GTextFiled;

        /* internal */ /* var */_contribution: GTextFiled;

        /* internal */ /* var */_multiSelect: GCheckBox;

        /* internal */ /* var */_leagueWarStarData: Vector.<GLoadedButton>;

        /* internal */ /* var */_bossStarData: Vector.<GLoadedButton>;

        /* internal */ /* var */_robCityStarData: Vector.<GLoadedButton>;

        /* internal */ /* var */_leagueWarStarSp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_bossStarSp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_robCitySp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_itemData: SGuildPlayerAttendanceVo;

        /* internal */ /* var */_bmpPost: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_selectLine: Object /* flash.display.Sprite */;

        /* internal */ /* var */_overSkin: Object /* flash.display.Sprite */;
    }
